// Kony

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/PlayerStart.h"
#include "GASC_HuanLing/GASC_HuanLing.h"
#include "Interaction/SaveInterface.h"
#include "Interaction/TargetInterface.h"
#include "Checkpoint.generated.h"

class USphereComponent;
/**
 * 检查点类 - 继承自玩家起始点类 就相当于暗黑2的小站 存储玩家开始位置用于传送
 * 继承 ISaveInterface 保存接口 这样保存世界状态时 就能保存检查点状态
 */
UCLASS()
class GASC_HUANLING_API ACheckpoint : public APlayerStart, public ISaveInterface ,public ITargetInterface
{
	GENERATED_BODY()
public:
	ACheckpoint(const FObjectInitializer& ObjectInitializer);
	/* 保存接口 Save Interface */
	//通过蓝图调用设置 Actor 是否保存变换
	virtual  bool ShouldLoadTransform_Implementation() override { return false; };
	//从存档中加载 Actor 状态
	virtual void LoadActor_Implementation() override;
	/* 保存接口 end Save Interface */
	//自定义深度模板覆盖值 蓝图可编辑
	UPROPERTY(EditDefaultsOnly)
	int32 CustomMDepthStencilOverride = CUSTOM_DEPTH_TAN;

	//移动到指定位置场景组件
	UPROPERTY(VisibleAnywhere)
	TObjectPtr<USceneComponent> MoveToLocation;
	//是否到达检查点 - SaveGame 保存游戏修饰符，标记为需要存储的状态变量
	UPROPERTY(BlueprintReadWrite, SaveGame)
	bool bReached = false;
	//是否触发碰撞回调函数 - 用于继承组件 不想触发碰撞时 从蓝图设置禁用碰撞回调
	UPROPERTY(EditAnywhere)
	bool bBindOverlapCallback = true;
protected:
	virtual void BeginPlay() override;
	/** Target Interface 目标接口 */
	virtual void HighlightActor_Implementation() override; //重写接口抽象类 设置高亮
	virtual void UnHighlightActor_Implementation() override; //重写接口抽象类 取消高亮
	virtual void SetMoveToLocation_Implementation(FVector& OutDestination) override; //重写缓存目的地接口
	/** end Target Interface */
	//处理碰撞函数
	UFUNCTION()
	virtual void OnSphereOverlap(UPrimitiveComponent* OverlappedComponent,AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);

	//设置动态材质实例动态变化函数 - 用于触发传送点后 点亮动态材质实例 - 蓝图原生事件
	UFUNCTION(BlueprintImplementableEvent)
	void CheckpointReached(UMaterialInstanceDynamic* DynamicMaterialInstance);

	//处理高光效果 - 蓝图可调用
	UFUNCTION(BlueprintCallable)
	void HandleGlowEffects();
	//用于蓝图设置的 - 检查点网格体
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
	TObjectPtr<UStaticMeshComponent> CheckpointMesh;
private:
	//用于蓝图设置的 - 碰撞体
	UPROPERTY(VisibleAnywhere)
	TObjectPtr<USphereComponent> Sphere;
	
};
